package com.tdtxdcxm.myparallelview.provider;

import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.PageSliderProvider;

import java.util.ArrayList;

public class PSProvider extends PageSliderProvider {
    ArrayList<DirectionalLayout> pageslist = new ArrayList<>();
    public PSProvider(ArrayList<DirectionalLayout> pageslist) {
        this.pageslist = pageslist;
    }

    @Override
    public int getCount() {
        return pageslist.size();
    }

    @Override
    public Object createPageInContainer(ComponentContainer componentContainer, int i) {
        DirectionalLayout directionalLayout = pageslist.get(i);

        componentContainer.addComponent(directionalLayout);

        return directionalLayout;
    }

    @Override
    public void destroyPageFromContainer(ComponentContainer componentContainer, int i, Object o) {
        componentContainer.removeComponent((Component) o);
    }

    @Override
    public boolean isPageMatchToObject(Component component, Object o) {
        return true;
    }
}
